package com.ffox.controller;

import com.ffox.result.Result;
import com.ffox.service.StudentLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 学生登录控制器
 */
@RestController
@RequestMapping("/login")
public class StudentLoginController {

    @Autowired
    private StudentLoginService studentLoginService;

    /**
     * 学生登录接口
     *
     * @param number   学生学号
     * @param password 学生密码
     * @return 登录结果
     */
    @PostMapping("/studentLogin")
    public Result<Map<String, Object>> studentLogin(@RequestParam String number, @RequestParam String password) {
        return studentLoginService.studentLogin(number, password);
    }

    /**
     * 学生注册接口
     *
     * @param number   学号
     * @param password 密码
     * @param realName 真实姓名
     * @param idCard   身份证号
     * @return 注册结果
     */
    @PostMapping("/studentInsert")
    public Result<Integer> studentInsert(@RequestParam String number, @RequestParam String password, @RequestParam String realName, @RequestParam String idCard, @RequestParam String userNum, @RequestParam String userIdCard) {
        return studentLoginService.studentInsert(number, password, realName, idCard, userNum, userIdCard);
    }

    /**
     * 学生删除接口
     *
     * @param id 学生ID
     * @return 删除结果
     */
    @PostMapping("/studentDelete/{id}")
    public Result<Integer> studentDelete(@PathVariable("id") Long id) {
        return studentLoginService.studentDelete(id);
    }
}
